package Events;

import Events.BaseEvent;
import shared.PlayerPortfolio;
import java.util.ArrayList;

/**
 * An single event that can contain multiple sub events
 * @author Joel Garboden
 */
public class CompositeEvent extends BaseEvent
{
  private ArrayList<BaseEvent> eventList;

  /**
   * Creates empty event list
   */
  public CompositeEvent()
  {
    eventList = new ArrayList<>();
  }
  /**
   * Function to execute events of an event
   * @param portfolio player's portfolio
   */
  @Override
  public final void execEvent(PlayerPortfolio portfolio)
  {
    for(BaseEvent event : eventList)
    {
      event.execEvent(portfolio);
    }
  }

  /**
   * Adds event to the event list
   * @param event event to add
   */
  public void addEvent(BaseEvent event)
  {
    eventList.add(event);
  }
}